﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml;
using System.Xml.Linq;

public partial class Admin_Quiz : System.Web.UI.Page
{
    ILE_Global ileGlobal = new ILE_Global();

    StandardsBLL standardsLogic = new StandardsBLL();
    LearnObjsBLL learnObjsLogic = new LearnObjsBLL();

    protected string xDocQuizStr
    {
        get
        {
            try
            {
                if (Session["xDocQuiz"].ToString() != String.Empty)
                {
                    return Session["xDocQuiz"].ToString();
                }
                else
                {
                    return String.Empty;
                }
            }
            catch
            {
                return String.Empty;
            }
            
        }
        set
        {
            Session["xDocQuiz"] = value.ToString();
        }
    }

    protected int LearnObjID
    {
        get
        {
            return (int)ViewState["LearnObjID"];
        }
        set
        {
            ViewState["LearnObjID"] = value;
        }
    }

    protected string QuizName
    {
        get
        {
            return (string)ViewState["QuizName"];
        }
        set
        {
            ViewState["QuizName"] = value;
        }
    }

    protected string LearnObjTitle
    {
        get
        {
            return (string)ViewState["LearnObjTitle"];
        }
        set
        {
            ViewState["LearnObjTitle"] = value;
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Page.IsPostBack == false)
        {
            LoadStandards();

            LearnObjID = Convert.ToInt32(ileGlobal.Validated(Request.QueryString["learnobjid"]));
            if (LearnObjID != 0)
            {
                LearnObjs.RelationsLearnObjStandardDataTable temp = learnObjsLogic.GetLearnObjStandardRelationshipsByLearnObjID(LearnObjID);
                ddlistStandards.SelectedValue = temp[0].StandardID.ToString();
                LoadLearnObjs();
                ddlistLearnObjs.SelectedValue = LearnObjID.ToString();

                loadQuizName();
                QuizName = txtQuizName.Text;
                WizardQuiz.ActiveStepIndex = 0;
            }
            else
            {
                LoadLearnObjs();
            }

            XDocument xDocQuiz = new XDocument();
            xDocQuizStr = xDocQuiz.ToString();
        }

        try
        {
            int UserID = Convert.ToInt32(Session["UserID"]);
        }
        catch (NullReferenceException ex)
        {
            ileGlobal.RecordError("Assignments_Quiz.aspx.cs:Page_Load:001", ex, "User Session Ended Unexpectedly", 3, Request.Browser);
            FormsAuthentication.SignOut();
            // *SteveMsg
            string _msg = "Your Session Information has ended. You have been logged out to prevent errors.";
            ModalPopupMessage.ShowModalPopup_Redirect("ILE Message", _msg, 2, "../Default.aspx");
        }
    }

    protected void LoadLearnObjs()
    {
        LearnObjs.RelationsLearnObjStandardDataTable learnObjs = learnObjsLogic.GetLearnObjsByStandardID(Convert.ToInt32(ddlistStandards.SelectedValue));
        ddlistLearnObjs.Items.Clear();

        if (learnObjs.Count >= 1)
        {
            ListItem newItem = new ListItem("-- Please Choose a LearnObj --", "0");
            ddlistLearnObjs.Items.Add(newItem);
        }
        else
        {
            ListItem newItem = new ListItem("-- No Available LearnObjs --", "0");
            ddlistLearnObjs.Items.Add(newItem);
        }

        foreach (LearnObjs.RelationsLearnObjStandardRow learnObj in learnObjs)
        {
            ListItem listItem = new ListItem(learnObj.Title.ToString(), learnObj.LearnObjID.ToString());
            ddlistLearnObjs.Items.Add(listItem);
        }
    }

    protected void LoadStandards()
    {
        Standards.StandardsDataTable standards = standardsLogic.GetStandards();

        ddlistStandards.Items.Clear();

        foreach (Standards.StandardsRow standard in standards)
        {
            ListItem listItem = new ListItem(standard.Standard.ToString(), standard.StandardID.ToString());
            ddlistStandards.Items.Add(listItem);
        }
    }

    protected void ddlistStandards_SelectedIndexChanged(object sender, EventArgs e)
    {
        LoadLearnObjs();
    }

    protected void ddlistLearnObjs_SelectedIndexChanged(object sender, EventArgs e)
    {
        loadQuizName();
    }

    protected void loadQuizName()
    {
        if (ddlistLearnObjs.SelectedValue != "0")
        {
            txtQuizName.Text = "Quiz for " + ddlistLearnObjs.SelectedItem.Text;
        }
        else
        {
            txtQuizName.Text = String.Empty;
            txtQuizName.Enabled = false;
            txtQuizName.BackColor = System.Drawing.Color.FromArgb(238, 238, 238);
        }
    }


    protected void WizardQuiz_NextButtonClick(object sender, WizardNavigationEventArgs e)
    {
        int LearnObjID = Convert.ToInt32(ddlistLearnObjs.SelectedValue);

        LearnObjs.LearnObjsRow learnObj = learnObjsLogic.GetLearnObj(LearnObjID);

        XDocument xDocQuiz = new XDocument();

        int ActiveIndex = Convert.ToInt32(WizardQuiz.ActiveStepIndex);
        switch (ActiveIndex)
        {
             case 0:
                LearnObjTitle = learnObj.Title;
                string QuizName = ileGlobal.Validated(txtQuizName.Text);
                if (learnObj.LearnObjQuizQuestions != String.Empty)
                {
                    xDocQuiz = XDocument.Parse(learnObj.LearnObjQuizQuestions);
                    xDocQuiz.Element("quiz").ReplaceAttributes(new XAttribute("name", QuizName));
                    foreach (XElement question in xDocQuiz.Descendants("question"))
                    {
                        try
                        {
                            xDocQuiz.Descendants("question").Where(
                                el => el.Attribute("id").Value == question.Attribute("id").Value).First().Add(
                                new XAttribute("excluded", "false"));
                        }
                        catch (InvalidOperationException ex)
                        {
                            // Do nothing
                        }
                        catch
                        {
                            // oops!
                        }
                    } 
                }
                else
                {
                    xDocQuiz = new XDocument();
                    xDocQuiz.Declaration = new XDeclaration("1.0", "utf-8", "yes");

                    xDocQuiz.Document.Add(new XElement("quiz",
                                            new XAttribute("name", QuizName),
                                            new XAttribute("learnobjid", LearnObjID.ToString()),
                                            new XAttribute("createdby", Session["UserID"].ToString()),
                                                new XElement("questions")));

                    xDocQuiz.Element("quiz").Element("questions").Add(
                            new XElement("question", new XAttribute("id", "1"), new XAttribute("difficulty", "normal"), new XAttribute("point", "2"), new XAttribute("defaultrequired", "false"), new XAttribute("excluded", "false")));

                }

                learnObjsLogic.UpdateLearnObj(learnObj.Title, learnObj.Link, learnObj.EstimatedTime, learnObj.Instruction, xDocQuiz.ToString(), LearnObjID);

                xDocQuizStr = xDocQuiz.ToString();

                FillQuestionsList();

                //List<XElement> _question = xDocQuiz.Descendants("question").Where(
                //    el => (int)el.Attribute("id") == 1).ToList();

                //if (_question[0].Attribute("defaultrequired").Value == "true")
                //    chkboxRequired.Checked = true;
                //else
                //    chkboxRequired.Checked = false;

                //switch (_question[0].Attribute("difficulty").Value)
                //{
                //    case "easy":
                //        ddlistDifficulty.SelectedIndex = 0;
                //        break;
                //    case "normal":
                //        ddlistDifficulty.SelectedIndex = 1;
                //        break;
                //    case "hard":
                //        ddlistDifficulty.SelectedIndex = 2;
                //        break;
                //    default:
                //        ddlistDifficulty.SelectedIndex = 1;
                //        break;
                //}

                //switch (_question[0].Attribute("point").Value)
                //{
                //    case "1":
                //        ddlistPoint.SelectedIndex = 0;
                //        break;
                //    case "2":
                //        ddlistPoint.SelectedIndex = 1;
                //        break;
                //    case "3":
                //        ddlistPoint.SelectedIndex = 2;
                //        break;
                //    default:
                //        ddlistPoint.SelectedIndex = 1;
                //        break;
                //}

                //txtQuestionText.Value = _question[0].Element("questiontext").Value;

                //List<XElement> _choice = xDocQuiz.Descendants("question").Descendants("choices").Descendants("choice").Where(
                //    el => (int)el.Parent.Parent.Attribute("id") == 1).ToList();

                //if (_choice.Count >= 1)
                //{
                //    txtChoice1.Text = _choice[0].Value;
                //    chkAnswer1.Checked = (_choice[0].Attribute("iscorrectanswer").Value == "true");
                //}
                //if (_choice.Count >= 2)
                //{
                //    txtChoice2.Text = _choice[1].Value;
                //    chkAnswer2.Checked = (_choice[1].Attribute("iscorrectanswer").Value == "true");
                //}
                //if (_choice.Count >= 3)
                //{
                //    txtChoice3.Text = _choice[2].Value;
                //    chkAnswer3.Checked = (_choice[2].Attribute("iscorrectanswer").Value == "true");
                //}
                //if (_choice.Count >= 4)
                //{
                //    txtChoice4.Text = _choice[3].Value;
                //    chkAnswer4.Checked = (_choice[3].Attribute("iscorrectanswer").Value == "true");
                //}
                //if (_choice.Count == 5)
                //{
                //    txtChoice5.Text = _choice[4].Value;
                //    chkAnswer5.Checked = (_choice[4].Attribute("iscorrectanswer").Value == "true");
                //}
                break;
            case 1:
                xDocQuiz = XDocument.Parse(xDocQuizStr);
                XmlDataSourceQuestionsOverview.EnableCaching = false;
                XmlDataSourceQuestionsOverview.Data = xDocQuiz.ToString();
                XmlDataSourceQuestionsOverview.DataBind();

                RepeaterQuestionsOverview.DataBind();

                RepeaterQuestionsOverview.Visible = true;
                break;
            default:
                break;
        }

        xDocQuizStr = xDocQuiz.ToString();
    }

    protected void FillQuestionsList()
    {
        XDocument xDocQuiz = new XDocument();
        if (xDocQuizStr != String.Empty)
        {
            xDocQuiz = XDocument.Parse(xDocQuizStr);
        }

        List<XElement> _list = xDocQuiz.Descendants("question").Where(
                    el => (int)el.Attribute("id") != 0).ToList();

        ddlistQuestionsList.Items.Clear();

        ListItem newItem = new ListItem("Add: A New Question", "0");
        ddlistQuestionsList.Items.Add(newItem);

        if (_list.Count > 0)
        {
            foreach (XElement element in _list)
            {
                string question = element.Element("questiontext").Value;
                question = System.Text.RegularExpressions.Regex.Replace(question, "<br />", " ");
                question = System.Text.RegularExpressions.Regex.Replace(question, "<[^>]*>", String.Empty);
                if (question.Length > 60)
                {
                    question = question.Substring(0, 60);
                    question = question + "...";
                }
                ListItem newItem2 = new ListItem();
                newItem2.Text = "Edit: " + element.Attribute("id").Value + " - " + question;
                newItem2.Value = element.Attribute("id").Value;
                ddlistQuestionsList.Items.Add(newItem2);
            }
        }

        txtQuestionText.Value = "New Question";
        txtChoice1.Text = String.Empty;
        txtChoice2.Text = String.Empty;
        txtChoice3.Text = String.Empty;
        txtChoice4.Text = String.Empty;
        txtChoice5.Text = String.Empty;

        btnUpdateQuestion.Visible = false;
        btnDeleteQuestion.Visible = false;
        btnAddNewQuestion.Visible = true;
    }

    protected void ddlistQuestionsList_SelectedIndexChanged(object sender, EventArgs e)
    {
        LoadQuestion();
    }

    protected void LoadQuestion()
    {
        int QuestionID = Convert.ToInt32(ddlistQuestionsList.SelectedValue);

        XDocument xDocQuiz = XDocument.Parse(xDocQuizStr);
        if (QuestionID == 0)
        {
            txtQuestionText.Value = "New Question";
            txtChoice1.Text = String.Empty;
            txtChoice2.Text = String.Empty;
            txtChoice3.Text = String.Empty;
            txtChoice4.Text = String.Empty;
            txtChoice5.Text = String.Empty;

            btnUpdateQuestion.Visible = false;
            btnDeleteQuestion.Visible = false;
            btnAddNewQuestion.Visible = true;

            chkboxExcluded.Checked = false;
            chkboxRequired.Checked = false;
        }
        else
        {
            
            List<XElement> _question = xDocQuiz.Descendants("question").Where(
                    el => (int)el.Attribute("id") == QuestionID).ToList();

            if (_question[0].Attribute("defaultrequired").Value == "true")
                chkboxRequired.Checked = true;
            else
                chkboxRequired.Checked = false;

            try
            {
                if (_question[0].Attribute("excluded").Value == "true")
                    chkboxExcluded.Checked = true;
                else
                    chkboxExcluded.Checked = false;
            }
            catch
            {
                _question[0].Add(new XAttribute("excluded", "false"));
            }

            switch (_question[0].Attribute("difficulty").Value)
            {
                case "easy":
                    ddlistDifficulty.SelectedIndex = 0;
                    break;
                case "normal":
                    ddlistDifficulty.SelectedIndex = 1;
                    break;
                case "hard":
                    ddlistDifficulty.SelectedIndex = 2;
                    break;
                default:
                    ddlistDifficulty.SelectedIndex = 1;
                    break;
            }

            switch (_question[0].Attribute("point").Value)
            {
                case "1":
                    ddlistPoint.SelectedIndex = 0;
                    break;
                case "2":
                    ddlistPoint.SelectedIndex = 1;
                    break;
                case "3":
                    ddlistPoint.SelectedIndex = 2;
                    break;
                default:
                    ddlistPoint.SelectedIndex = 1;
                    break;
            }

            txtQuestionText.Value = _question[0].Element("questiontext").Value;

            List<XElement> _choice = xDocQuiz.Descendants("question").Descendants("choices").Descendants("choice").Where(
                el => (int)el.Parent.Parent.Attribute("id") == QuestionID).ToList();

            txtChoice1.Text = String.Empty;
            txtChoice2.Text = String.Empty;
            txtChoice3.Text = String.Empty;
            txtChoice4.Text = String.Empty;
            txtChoice5.Text = String.Empty;

            if (_choice.Count >= 1)
            {
                txtChoice1.Text = _choice[0].Value;
                chkAnswer1.Checked = (_choice[0].Attribute("iscorrectanswer").Value == "true");
            }
            if (_choice.Count >= 2)
            {
                txtChoice2.Text = _choice[1].Value;
                chkAnswer2.Checked = (_choice[1].Attribute("iscorrectanswer").Value == "true");
            }
            if (_choice.Count >= 3)
            {
                txtChoice3.Text = _choice[2].Value;
                chkAnswer3.Checked = (_choice[2].Attribute("iscorrectanswer").Value == "true");
            }
            if (_choice.Count >= 4)
            {
                txtChoice4.Text = _choice[3].Value;
                chkAnswer4.Checked = (_choice[3].Attribute("iscorrectanswer").Value == "true");
            }
            if (_choice.Count == 5)
            {
                txtChoice5.Text = _choice[4].Value;
                chkAnswer5.Checked = (_choice[4].Attribute("iscorrectanswer").Value == "true");
            }

            btnUpdateQuestion.Visible = true;
            btnDeleteQuestion.Visible = true;
            btnAddNewQuestion.Visible = false;
        }

        xDocQuizStr = xDocQuiz.ToString();
    }

    protected void btnUpdateQuestion_Click(object sender, EventArgs e)
    {
        int LearnObjID = Convert.ToInt32(ddlistLearnObjs.SelectedValue);
        // GET THE Question ID
        int QuestionID = Convert.ToInt32(ddlistQuestionsList.SelectedValue);

        XDocument xDocQuiz = XDocument.Parse(xDocQuizStr);

        XElement question = xDocQuiz.Descendants("question").First(
                    el => (int)el.Attribute("id") == QuestionID);
        question.ReplaceAttributes(new XAttribute("id", QuestionID.ToString()),
            new XAttribute("difficulty", ddlistDifficulty.SelectedValue),
            new XAttribute("point", ddlistPoint.SelectedValue),
            new XAttribute("defaultrequired", chkboxRequired.Checked ? "true" : "false"),
            new XAttribute("excluded", chkboxExcluded.Checked ? "true" : "false"));
        question.Element("questiontext").Value = txtQuestionText.Value;

        question.Descendants("choice").Remove();

        XElement choices = question.Descendants("choices").First();

        bool flag_AtLeastOneAnswer = false;
        if (txtChoice1.Text != String.Empty)
        {
            choices.Add(new XElement("choice", new XAttribute("iscorrectanswer", chkAnswer1.Checked ? "true" : "false"), txtChoice1.Text));
            if (flag_AtLeastOneAnswer == false)
            {
                flag_AtLeastOneAnswer = chkAnswer1.Checked;
            }
        }
        if (txtChoice2.Text != String.Empty)
        {
            choices.Add(new XElement("choice", new XAttribute("iscorrectanswer", chkAnswer2.Checked ? "true" : "false"), txtChoice2.Text));
            if (flag_AtLeastOneAnswer == false)
            {
                flag_AtLeastOneAnswer = chkAnswer2.Checked;
            }
        }
        if (txtChoice3.Text != String.Empty)
        {
            choices.Add(new XElement("choice", new XAttribute("iscorrectanswer", chkAnswer3.Checked ? "true" : "false"), txtChoice3.Text));
            if (flag_AtLeastOneAnswer == false)
            {
                flag_AtLeastOneAnswer = chkAnswer3.Checked;
            }
        }
        if (txtChoice4.Text != String.Empty)
        {
            choices.Add(new XElement("choice", new XAttribute("iscorrectanswer", chkAnswer4.Checked ? "true" : "false"), txtChoice4.Text));
            if (flag_AtLeastOneAnswer == false)
            {
                flag_AtLeastOneAnswer = chkAnswer4.Checked;
            }
        }
        if (txtChoice5.Text != String.Empty)
        {
            choices.Add(new XElement("choice", new XAttribute("iscorrectanswer", chkAnswer5.Checked ? "true" : "false"), txtChoice5.Text));
            if (flag_AtLeastOneAnswer == false)
            {
                flag_AtLeastOneAnswer = chkAnswer5.Checked;
            }
        }

        if (flag_AtLeastOneAnswer == false)
        {
            string _message = "Please Check at least One Answer.";
            ModalPopupMessage.ShowModalPopup("ILE Message", _message, 2);
        }
        else
        {
            LearnObjs.LearnObjsRow learnObj = learnObjsLogic.GetLearnObj(LearnObjID);
            bool result = learnObjsLogic.UpdateLearnObj(learnObj.Title, learnObj.Link, learnObj.EstimatedTime, learnObj.Instruction, xDocQuiz.ToString(), LearnObjID);
            if (result)
            {
                // *SteveMsg
                xDocQuizStr = xDocQuiz.ToString();
                string _message = "Question Successfully Updated.";
                ModalPopupMessage.ShowModalPopup("ILE Message", _message, 1);
                FillQuestionsList();
                ddlistQuestionsList.SelectedValue = QuestionID.ToString();
                LoadQuestion();
            }
            else
            {
                // *SteveMsg
                string _message = "Failed to Update the Question.";
                ModalPopupMessage.ShowModalPopup("ILE Message", _message, 2);
            }
        }
    }
    protected void btnAddNewQuestion_Click(object sender, EventArgs e)
    {
        int LearnObjID = Convert.ToInt32(ddlistLearnObjs.SelectedValue);
        int QuestionID = 0;

        XDocument xDocQuiz = new XDocument();
        if (xDocQuizStr != String.Empty)
        {
            xDocQuiz = XDocument.Parse(xDocQuizStr);
        }

        try
        {
            QuestionID = Convert.ToInt32(xDocQuiz.Descendants("question").Last().Attribute("id").Value);
        }
        catch
        {
        }
        finally
        {
            QuestionID++;
        }
        

        XElement question = new XElement("question",
            new XAttribute("id", QuestionID.ToString()),
            new XAttribute("difficulty", ddlistDifficulty.SelectedValue),
            new XAttribute("point", ddlistPoint.SelectedValue),
            new XAttribute("defaultrequired", chkboxRequired.Checked ? "true" : "false"),
            new XAttribute("excluded", chkboxRequired.Checked ? "true" : "false"));

        question.Add(new XElement("questiontext", txtQuestionText.Value));;

        question.Add(new XElement("choices"));

        bool flag_AtLeastOneAnswer = false;
        if (txtChoice1.Text != String.Empty)
        {
            question.Element("choices").Add(new XElement("choice", new XAttribute("iscorrectanswer", chkAnswer1.Checked ? "true" : "false"), txtChoice1.Text));
            if (flag_AtLeastOneAnswer == false)
            {
                flag_AtLeastOneAnswer = chkAnswer1.Checked;
            }
        }
        if (txtChoice2.Text != String.Empty)
        {
            question.Element("choices").Add(new XElement("choice", new XAttribute("iscorrectanswer", chkAnswer2.Checked ? "true" : "false"), txtChoice2.Text));
            if (flag_AtLeastOneAnswer == false)
            {
                flag_AtLeastOneAnswer = chkAnswer2.Checked;
            }
        }
        if (txtChoice3.Text != String.Empty)
        {
            question.Element("choices").Add(new XElement("choice", new XAttribute("iscorrectanswer", chkAnswer3.Checked ? "true" : "false"), txtChoice3.Text));
            if (flag_AtLeastOneAnswer == false)
            {
                flag_AtLeastOneAnswer = chkAnswer3.Checked;
            }
        }
        if (txtChoice4.Text != String.Empty)
        {
            question.Element("choices").Add(new XElement("choice", new XAttribute("iscorrectanswer", chkAnswer4.Checked ? "true" : "false"), txtChoice4.Text));
            if (flag_AtLeastOneAnswer == false)
            {
                flag_AtLeastOneAnswer = chkAnswer4.Checked;
            }
        }
        if (txtChoice5.Text != String.Empty)
        {
            question.Element("choices").Add(new XElement("choice", new XAttribute("iscorrectanswer", chkAnswer5.Checked ? "true" : "false"), txtChoice5.Text));
            if (flag_AtLeastOneAnswer == false)
            {
                flag_AtLeastOneAnswer = chkAnswer5.Checked;
            }
        }

        if (flag_AtLeastOneAnswer == false)
        {
            string _message = "Please Check at least One Answer.";
            ModalPopupMessage.ShowModalPopup("ILE Message", _message, 2);
            return;
        }

        xDocQuiz.Element("quiz").Element("questions").Add(question);

        LearnObjs.LearnObjsRow learnObj = learnObjsLogic.GetLearnObj(LearnObjID);

        bool result = learnObjsLogic.UpdateLearnObj(learnObj.Title, learnObj.Link, learnObj.EstimatedTime, learnObj.Instruction, xDocQuiz.ToString(), LearnObjID);
        if (result)
        {
            xDocQuizStr = xDocQuiz.ToString();
            // *SteveMsg
            string _message = "New Question has been added.";
            ModalPopupMessage.ShowModalPopup("ILE Message", _message, 1);
            FillQuestionsList();
            ddlistQuestionsList.SelectedIndex = ddlistQuestionsList.Items.Count - 1;
            LoadQuestion();
        }
    }


    protected void btnDeleteQuestion_Click(object sender, EventArgs e)
    {
        int LearnObjID = Convert.ToInt32(ddlistLearnObjs.SelectedValue);
        int QuestionID = Convert.ToInt32(ddlistQuestionsList.SelectedValue);

        XDocument xDocQuiz = XDocument.Parse(xDocQuizStr);

        try
        {
            xDocQuiz.Descendants("question").Where(el => (int)el.Attribute("id") == QuestionID).First().Remove();
        }
        catch
        {
            string _message = "Failed to delete the Question..";
            ModalPopupMessage.ShowModalPopup("ILE Message", _message, 2);
            return;
        }

        LearnObjs.LearnObjsRow learnObj = learnObjsLogic.GetLearnObj(LearnObjID);
        bool result = learnObjsLogic.UpdateLearnObj(learnObj.Title, learnObj.Link, learnObj.EstimatedTime, learnObj.Instruction, xDocQuiz.ToString(), LearnObjID);
        if (result)
        {
            xDocQuizStr = xDocQuiz.ToString();
            int selectedIndex = ddlistQuestionsList.SelectedIndex;
            FillQuestionsList();
            ddlistQuestionsList.SelectedIndex = selectedIndex - 1;
            LoadQuestion();
        }
        else
        {
            string _message = "Failed to delete the Question..";
            ModalPopupMessage.ShowModalPopup("ILE Message", _message, 2);
            return;
        }

    }
    // FILL QUESTION LIST
    protected void WizardQuiz_FinishButtonClick(object sender, WizardNavigationEventArgs e)
    {
        // *SteveMsg
        string _message = "Quiz Questions have been updated!";
        ModalPopupMessage.ShowModalPopup_Redirect("ILE Message", _message, 1, "Quiz.aspx");
    }

}
